package org.elzat.healthboxgatewayapp.util;

import lombok.experimental.UtilityClass;
import org.elzat.healthboxgatewayapp.credentials.HealthBoxUserRole;
import org.elzat.healthboxgatewayapp.dto.HealthBoxUser;
import org.elzat.healthboxgatewayapp.dto.HealthBoxUserEntity;
import org.elzat.healthboxgatewayapp.dto.HealthBoxUserVO;

import java.util.ArrayList;
import java.util.List;

@UtilityClass
public class DataConversionUtil {

    public List<HealthBoxUserVO> convert(List<HealthBoxUserEntity> entities) {
        List<HealthBoxUserVO> vos = new ArrayList<>();
        for (HealthBoxUserEntity entity : entities)
            vos.add(convert(entity));
        return vos;
    }


    public HealthBoxUserVO convert(HealthBoxUserEntity entity) {
        return HealthBoxUserVO
                .builder()
                .id(entity.getId())
                .locked(entity.getLocked())
                .userPhone(entity.getUserPhone())
                .idNumber(entity.getIdNumber())
                .name(entity.getName())
                .role(HealthBoxUserRole.valueOf(entity.getRole()))
                .build();
    }
}
